package com.xiaoshuidi.cloud.framework.pay.core.client.impl.yinlian;

import com.xiaoshuidi.cloud.framework.common.exception.ErrorCode;
import com.xiaoshuidi.cloud.framework.common.exception.enums.GlobalErrorCodeConstants;
import com.xiaoshuidi.cloud.framework.pay.core.client.AbstractPayCodeMapping;
import com.xiaoshuidi.cloud.framework.pay.core.enums.PayFrameworkErrorCodeConstants;

public class YinlianCodeMapping extends AbstractPayCodeMapping {
    @Override
    protected ErrorCode apply0(String apiCode, String apiMsg) {
        switch (apiCode) {
            case "SUCCESS":
                return GlobalErrorCodeConstants.SUCCESS;
            case "INTERNAL_ERROR":
            case "BAD_REQUEST":
            case "NO_SERVICE":
            case "TIMEOUT":
            case "ABNORMAL_REQUEST_TIME":
            case "TXN_DISCARDED":
            case "BAD_SIGN":
            case "INVALID_MSGSRC":
            case "INVLID_MERCHANT_CONFIG":
            case "INVALID_RESPONSE":

            case "NO_CROSS_DAY_TRADING":
            case "DENIED_IP":
            case "INVALID_ORDER":
            case "NO_ORDER":
            case "OPERATION_NOT_ALLOWED":
            case "ORDER_PROCESSING":
            case "INACTIVE_MERCHANT":

            case "TARGET_FAIL":
            case "DUP_ORDER":
            case "NET_ERROR":
            case "NO_MERCHANT":
            case "INVALID_ORDER_ID":
                return new ErrorCode(PayFrameworkErrorCodeConstants.PAY_PARAM_WRONG.getCode(), apiMsg);
            case "1000":
                return PayFrameworkErrorCodeConstants.PAY_CONFIG_APP_ID_ERROR;
            default:
                return GlobalErrorCodeConstants.INTERNAL_SERVER_ERROR;
        }
    }
}
